#ifndef __LINKAGE_TABLE_H__
#define __LINKAGE_TABLE_H__

#include <stdint.h>

#include "linkageConditionTable.h"
#include "linkageActionTable.h"

//
typedef struct _LINKAGE{
    int64_t  id;          //协议ID
    int64_t  round;       //查询轮次,每次任务执行一轮+1
    int      isRound;     //是否按一轮数据，来决定动作与否，默认1， 0-否，1-是
    char     name[32];    //协议名称
    char     desc[256];   //协议描述 
    int      order;       //执行顺序
    struct _LINKAGE* prev;
    struct _LINKAGE* next;
}T_LINKAGE;

/**
 * @brief 测点模型
 */
typedef struct _LINKAGE_LIST{
    int  count;
    T_LINKAGE* tail;
    T_LINKAGE* head;
}T_LINKAGE_LIST;


extern void dbLinkageInit();
extern int  createLinkageTable();
extern int  insertLinkage(T_LINKAGE* linkage);
extern int  replaceLinkage(T_LINKAGE* linkage);
extern int  deleteLinkage(T_LINKAGE* linkage);
extern int  selectLinkage(const char* sql, T_LINKAGE_LIST* linkageList);



#endif // __LINKAGE_TABLE_H__